import { get, post, put, del } from "@/request";

export interface IInforArticle {
  articleId?: number | string | null;
  articleTitle: string;
  articleContent: string;
  articleImg?: string;
  status?: number; // 0-无效,1-有效
  publishTime?: string;
  createTime?: string;
  updateTime?: string;
}

// 新增健康科普文章
export const createInforArticle = (data: IInforArticle) => {
  return post("/information/article/addArticle", data);
};

// 删除健康科普文章
export const deleteInforArticle = (articleId: number | string) => {
  return del(`/information/article/${articleId}`);
};

// 查询所有健康科普文章
export const fetchAllInforArticles = () => {
  return get<{ data: IInforArticle[] }>("/information/article");
};

// 更新健康科普文章
export const updateInforArticle = (data: IInforArticle) => {
  return put("/information/article/updateArticle", data);
};

// 根据id查询单个健康科普文章
export const fetchInforArticle = (articleId: number | string) => {
  return get(`/information/article/${articleId}`);
}